const form=document.querySelector('.user-form');
const userCheck=new FieldValidator('txtLoginId',async (val)=>{
    if(!val){
        return '请填写账号'
    }
})
const pwdCheck=new FieldValidator('txtLoginPwd',async (val)=>{
    if(!val){
        return '请填写密码'
    }
})
form.onsubmit=async (e)=>{
    e.preventDefault();
    const result=FieldValidator.runAllcheck(userCheck,pwdCheck);
    if(result){
        const resp=await API.login({
            loginId:userCheck.input.value,
            loginPwd:pwdCheck.input.value
        })
        if(resp.code===0){
            alert('登录成功,跳转至主页')
            location.href = './index.html';
        }else{
            pwdCheck.errInput.innerText='帐号或密码错误';
            userCheck.input.value='';
            pwdCheck.input.value='';
        }
    }
}